package edu.zzuli.service.impl;

import edu.zzuli.dao.RegeistDao;
import edu.zzuli.pojo.User;
import edu.zzuli.service.RegeistService;
import edu.zzuli.utils.MailUtil;

import java.sql.SQLException;

/**
 * Created by Chen-D.W on 2017/12/25.
 */
public class RegeistServiceImpl implements RegeistService{


    @Override
    public void createdUser(User user) throws Exception {
        RegeistDao dao=new RegeistDao();
        dao.insert(user);
//        MailUtil.sendMail(user.getMail(),user.getCode());
        MailUtil mail=new MailUtil(user.getMail(),user.getCode());
        Thread th=new Thread(mail);
        th.start();
    }

    @Override
    public User getUser(String code) throws SQLException {
        return new RegeistDao().check(code);
    }

    @Override
    public void update(User user) throws SQLException {
        RegeistDao.update(user);
    }
}
